package st.business.tepth.business.driverinfo;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import st.business.tepth.R;
import st.business.tepth.business.bean.WorkDetailContentBean;
import st.business.tepth.config.ItemFields;
import st.shadow.library.ui.recycler.MultipleItemEntity;

/**
 * @author zhangyu
 * @date 2019/2/23
 */
public class WorkDetailInfoAdapter extends BaseMultiItemQuickAdapter<MultipleItemEntity,
        BaseViewHolder> {
    public static final int TYPE_0 = 0;
    public static final int TYPE_1 = 1;
    public static final int TYPE_2 = 2;
    public static final int TYPE_3 = 3;

    /**
     * Same as QuickAdapter#QuickAdapter(Context,int) but with
     * some initialization data.
     *
     * @param data A new list is created out of this one to avoid mutable list
     */
    public WorkDetailInfoAdapter(List<MultipleItemEntity> data) {
        super(data);
        addItemType(TYPE_0, R.layout.item_work_detail_info_type_0);
        addItemType(TYPE_1, R.layout.item_work_detail_info_type_1);
        addItemType(TYPE_2, R.layout.item_work_detail_info_type_2);
        addItemType(TYPE_3, R.layout.item_work_detail_info_type_3);
    }


    @Override
    protected void convert(final BaseViewHolder helper, final MultipleItemEntity item) {
        switch (helper.getItemViewType()) {
            case TYPE_0:
                helper.setText(R.id.tv_classification,
                        (CharSequence) item.getField("classification"));
                helper.setText(R.id.tv_trouble,
                        (CharSequence) item.getField("trouble"));
                helper.setText(R.id.tv_work_content,
                        (CharSequence) item.getField("workItem"));
                break;
            case TYPE_1:
                WorkDetailContentBean.ReceiveGoodsDetail bean = item.getField(ItemFields.ITEM_OBJ);
                helper.setText(R.id.tv_apply_time, bean.getApplyTime());
                helper.setText(R.id.tv_apply_person, bean.getApplyName());
                helper.setText(R.id.tv_part_name, bean.getPartName());
                helper.setText(R.id.tv_part_code, bean.getPartCode());
                helper.setText(R.id.tv_store_room, bean.getStoreRoom());
                helper.setText(R.id.tv_apply_count, bean.getApplyCount() + "");
                helper.setText(R.id.tv_check_state, bean.getCheckState());
                helper.setText(R.id.tv_goods_receive_state, bean.getReceiveRecord());
                break;
            case TYPE_2:

                break;
            case TYPE_3:

                WorkDetailContentBean.OperationPerson operationPerson
                        = item.getField(ItemFields.ITEM_OBJ);
                helper.setText(R.id.tv_work_step, operationPerson.getStep());
                helper.setText(R.id.tv_work_person, operationPerson.getPersons());
                helper.setText(R.id.tv_work_start_time, operationPerson.getStartTime());
                helper.setText(R.id.tv_work_end_time, operationPerson.getEndTime());
                helper.setText(R.id.tv_work_continue_time, operationPerson.getContinueTime());
                break;
        }
    }

}
